package edu.unika.aifb.graphindex.index;

import java.io.IOException;

import edu.unika.aifb.graphindex.storage.IndexStorage;
import edu.unika.aifb.graphindex.storage.StorageException;
import edu.unika.aifb.graphindex.storage.lucene.LuceneIndexStorage;

public class DBIndex extends Index{
	private IndexStorage dbIndexStorage;
	public DBIndex(IndexReader indexReader, boolean warmup) {
		super(indexReader, warmup);
	}

	public IndexStorage getDBIndexStorage() throws IOException {
		if (dbIndexStorage == null) {
			dbIndexStorage = new LuceneIndexStorage(m_idxDirectory.getDirectory(IndexDirectory.DB_IDX_DIR), m_idxReader.getCollector());
			dbIndexStorage.initialize(false, true);
		}
		return dbIndexStorage;
	}
	
	@Override
	public void close() throws StorageException {
		if(dbIndexStorage != null)
			dbIndexStorage.close();
	}

}
